﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Wormhole.Engine.Communication
{
	/// <author>Hannes Foulds</author>
	/// <date>05 September 2008</date>
	/// <summary>
	/// This class represents a card in the deck.
	/// </summary>
	public class Card
	{
		#region Properties

		#region ID
		/// <summary>
		/// The unique ID of the card to help identify the exact copy in the game.
		/// </summary>
		public int ID { get; set; }
		#endregion

		#region Card Name
		/// <summary>
		/// The name of the card that will be used to locate it in the card pool.
		/// </summary>
		public string CardName { get; set; }
		#endregion

		#endregion

		#region Constructor
		/// <summary>
		/// Initialize a default instance of the class.
		/// </summary>
		public Card()
		{
		}

		/// <summary>
		/// Create a card form the card string provided.
		/// </summary>
		/// <param name="cardString">The card string to parse.</param>
		public Card(string cardString) : this()
		{
			this.FromString(cardString);
		}
		#endregion

		#region To String
		/// <summary>
		/// Convert the card to its string representation.
		/// </summary>
		/// <returns></returns>
		public override string ToString()
		{
			return string.Format("{0},{1}", this.ID, this.CardName);
		}
		#endregion

		#region From String
		/// <summary>
		/// Parse the string representation of a card.
		/// </summary>
		/// <param name="cardString">The string representation.</param>
		public void FromString(string cardString)
		{
			string[] stringParts = cardString.Split(',');
			this.ID = Convert.ToInt32(stringParts[0]);
			this.CardName = stringParts[1];
		}
		#endregion
	}
}
